* This file sets up two locals (texpreamble and texpostamble) so that one can write
* only write manually the tabular environment (for complex layouts) in the do-file 
* and set the footnote (in a threeparttable) with the `notes' local


* Texpreamble 

local texpreamble = "`texpreamble'%------- Packages and Set up ------- %" + char(10)
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'% Page formatting" + char(10)
local texpreamble = "`texpreamble'\documentclass{article}" + char(10)
local texpreamble = "`texpreamble'\usepackage[a4paper,margin=0.5in,landscape]{geometry}" + char(10)
local texpreamble = "`texpreamble'\pagenumbering{gobble}" + char(10)
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'% Typography and characters" + char(10)
local texpreamble = "`texpreamble'\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}" + char(10)
local texpreamble = "`texpreamble'\usepackage{lmodern}" + char(10)
local texpreamble = "`texpreamble'\usepackage[english]{babel}" + char(10)
local texpreamble = "`texpreamble'\usepackage[T1]{fontenc}" + char(10)
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'% Table formatting" + char(10)
local texpreamble = "`texpreamble'\usepackage{threeparttable}" + char(10)
local texpreamble = "`texpreamble'\usepackage{booktabs}" + char(10)
local texpreamble = "`texpreamble'\usepackage{multirow}" + char(10)
local texpreamble = "`texpreamble'\usepackage{makecell}" + char(10)
local texpreamble = "`texpreamble'\renewcommand{\arraystretch}{1.05} % set row height" + char(10)
local texpreamble = "`texpreamble'\usepackage{siunitx} " + char(10)
local texpreamble = "`texpreamble'\sisetup{ " + char(10)
local texpreamble = "`texpreamble'    input-symbols = () []," + char(10)
local texpreamble = "`texpreamble'    input-decimal-markers = {.}," + char(10)
local texpreamble = "`texpreamble'    table-space-text-pre = -," + char(10)
local texpreamble = "`texpreamble'    table-space-text-post = \sym{***}," + char(10)
local texpreamble = "`texpreamble'    table-align-text-post = false," + char(10)
local texpreamble = "`texpreamble'    table-format=1.2 % change in tabular S[] if not default" + char(10)
local texpreamble = "`texpreamble'}" + char(10)
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'% Math, symbol, and number formatting" + char(10)
local texpreamble = "`texpreamble'\usepackage{amsmath}" + char(10)
local texpreamble = "`texpreamble'\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} % define \sym (significance stars)" + char(10)
local texpreamble = "`texpreamble'\def\stimes{\kern -0.25em $\times$ \kern -0.25em} % define \sstimes (\times with smaller kerning and in text env)" + char(10)
local texpreamble = "`texpreamble'\def\nsk{\noalign{\smallskip}} % define \nsk to make a small skip between rows in the label" + char(10)
local texpreamble = "`texpreamble'\def\yes{{Yes}} % define \yes (FE indicator)" + char(10)
local texpreamble = "`texpreamble'\def\no{{No}}	% define \no (FE indicator)" + char(10)
local texpreamble = "`texpreamble'\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % define \mc as shortcut for centered multicolumn" + char(10)
local texpreamble = "`texpreamble'\newcommand{\mypc}[1]{\hfill \; (\SI{#1}{\percent})} % define \mpyc as shortcut for percent after number in parentheses" + char(10)
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'%------- Begin Document ------- %" + char(10)
local texpreamble = "`texpreamble'\begin{document}" + char(10)
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'%------- Begin Table ------- %"
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'\begin{table}[htbp]" + char(10) 
local texpreamble = "`texpreamble'\centering" + char(10)
local texpreamble = "`texpreamble'\small" + char(10)
local texpreamble = "`texpreamble'\begin{threeparttable}" + char(10)
local texpreamble = "`texpreamble'" + char(10)
local texpreamble = "`texpreamble'%------- Tabular ------- %"
local texpreamble = "`texpreamble'" + char(10)

* Custom tabular in do-file .... 

* Texpostamble
local note_pvalues " Significance levels at *10\%, **5\%, ***1\%."
if `"`notes'"' != "" {
    local texpostamble = "`texpostamble'%------- Table Note ------- %"
    local texpostamble = "`texpostamble'" + char(10)
    local texpostamble = "`texpostamble'\begin{tablenotes}[para,flushleft]" + char(10) 
    local texpostamble = "`texpostamble'Note.-- " + `"`notes'"'  + char(10) 
    if `"`show_pvalues_note'"' == "yes" {
        local texpostamble = "`texpostamble'`note_pvalues'" + char(10) 
    } 
    local texpostamble = "`texpostamble'\end{tablenotes}" + char(10)
    local texpostamble = "`texpostamble'" + char(10)
}
local texpostamble = "`texpostamble'%------- End Table ------- %"
local texpostamble = "`texpostamble'" + char(10)
local texpostamble = "`texpostamble'\end{threeparttable}" + char(10) 
local texpostamble = "`texpostamble'\end{table}" + char(10)
local texpostamble = "`texpostamble'" + char(10)
local texpostamble = "`texpostamble'%------- End Document ------- %" + char(10)
local texpostamble = "`texpostamble'" + char(10)
local texpostamble = "`texpostamble'\end{document}" + char(10)
local texpostamble = "`texpostamble'" + char(10)

